package com.tech.view.panel;

import com.tech.util.LogProcessUtil;
import com.tech.view.frame.MainFrame;

import javax.swing.*;
import java.awt.*;
import java.util.logging.Logger;

/**
 * 首页内容面板
 */
public class IndexPanel extends JPanel implements PanelLifeCycle {
	private final static Logger LOG = LogProcessUtil.getLogger(IndexPanel.class.getName());
	private MainFrame frame;

	private PortDisplayPanel portDisplayPanel;
	private HOTPanel hotPanel;

	public IndexPanel(MainFrame frame) {
		this.frame = frame;
	}

	private void initService() {

	}

	private void initComponents() {
		portDisplayPanel = new PortDisplayPanel();
		hotPanel = new HOTPanel(frame);
	}

	private void initView() {
		setPreferredSize(new Dimension(860, 1500));
		setLayout(new BorderLayout());
		add(portDisplayPanel, BorderLayout.NORTH);
		add(hotPanel);
	}

	private void setListeners() {
	}

	public PortDisplayPanel getPortDisplayPanel() {
		return portDisplayPanel;
	}

	public void setPortDisplayPanel(PortDisplayPanel portDisplayPanel) {
		this.portDisplayPanel = portDisplayPanel;
	}

	public HOTPanel getHotPanel() {
		return hotPanel;
	}

	public void setHotPanel(HOTPanel hotPanel) {
		this.hotPanel = hotPanel;
	}

	@Override
	public void start() {
		initService();
		initComponents();
		setListeners();
		initView();
	}

	@Override
	public boolean end() {
		// 切换前关闭轮播动画
		portDisplayPanel.stopAnimation();
		return true;
	}
}
